package top.roadvast.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * @Author 郭泽鹏
 * @Date 2020/6/26 11:07
 * @Version 1.0
 * @Description 启动流程实例，添加进businessKey
 */
public class BusinessKeyAdd {
    public static void main(String[] args) {
        //创建ProcessEngine对象
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();

        //创建RuntimeService对象
        RuntimeService runtimeService = defaultProcessEngine.getRuntimeService();

        //启动流程实例对象，
        //第一个参数：指定流程定义的key
        //第二个参数：业务标识BusinessKey
        ProcessInstance holiday = runtimeService.startProcessInstanceByKey("holiday", "1001");

        //输出ProcessInstance相关的属性
        System.out.println("流程实例的ID号：" + holiday.getProcessInstanceId());
        System.out.println(holiday.getBusinessKey());

    }
}